import urllib,urllib2
import scrapy
class MyDownloaderMiddleware(object):
    def process_request(self,request,spider):
        url =request.url
        resp =urllib2.urlopen(urllib2.Request(url))
        return scrapy.http.HtmlResponse(url=url,body=resp.read())
        ##return resp
class MySpiderMiddleware(object):
    #def process_output(self,res)
    def process_spider_exception(self,response,exception,spider):
        print 'process_spider_exception'